<form class="form-horizontal">
  <div class="control-group">
    <h3>{{ _('General options') }}</h3>
    <label class="checkbox"><input type="checkbox" data-bind="checked: exactDurations">{{ _('Display precise durations instead of fuzzy ones') }}</label>
    <label class="checkbox"><input type="checkbox" data-bind="checked: showStars">{{ _('Show gold stars next to PrintTimeGenius-analyzed gcode files') }}</label>
    <label class="checkbox"><input type="checkbox" data-bind="checked: enableOctoPrintAnalyzer">{{ _('Enable OctoPrint\'s built-in analyzer (slow and unnecessary)') }}</label>
    <label title="{{ _('Analyzing a file while heating should not affect performace.') }}"
           class="checkbox"><input
                              type="checkbox"
                              data-bind="checked: allowAnalysisWhileHeating">{{ _('Allow analysis while heating (only takes effect after saving)') }}</label>
    <label title="{{ _('Analyzing a file while printing might cause poor printing performace.') }}"
           class="checkbox"><input
                              type="checkbox"
                              data-bind="checked: allowAnalysisWhilePrinting">{{ _('Allow analysis while printing (only takes effect after saving)') }}<span class="label label-important">{{ _('May slow down your printer') }}</span></label>
    <h3>{{ _('Analyzers') }}</h3>
    <!-- ko foreach: analyzers -->
      <label class="checkbox">
        <input type="checkbox" data-bind="checked: enabled"><div type="checkbox" data-bind="text: description"></div>
      </label>
    <!-- /ko -->
    <h3>{{ _('Analyze') }}</h3>
    {{ _('You can use this to run an analysis right now and also look at the output to debug problems.') }}
    <div class="row-fluid" data-bind="if: filesViewModel.allItems()">
      <label class="span9">{{ _('Files to analyze:') }}
        <select class="span9" id="stlviewer_file_list" multiple="true"
                data-bind="options: FileList,
                           optionsText: function(item) {
                             if(_.has(item, 'gcodeAnalysis.progress')) {
                               return item.path + ' ★';
                             } else if(_.has(item, 'gcodeAnalysis.analysisPending')) {
                               return item.path + ' ⌛';
                             } else {
                               return item.path;
                             }
                           },
                           selectedOptions: selectedGcodes,
                           event: { }">
        </select>
      </label>
      <button class="btn" data-bind="event: { click: analyzeCurrentFile }">{{ _('Analyze') }}</button>
    </div>

    <div>
      <div>
        <small>
          <a href="#" class="muted" onclick="$(this).children().toggleClass('fa-caret-right fa-caret-down').parent().parent().parent().next().slideToggle('fast')">
            <i class="fa fa-caret-right"></i> {{ _('Advanced') }}
          </a>
        </small>
      </div>
      <div class="hide" style="display: none;">
        <h3>{{ _('Analyzers') }}</h3>
        <button class="btn" title="{{ _('The default analyzers are the suggested settings for all users') }}"
                data-bind="event: { click: resetAnalyzersToDefault }">{{ _('Reset analyzers to default') }}</button>
        <div class="row-fluid">
          <h4 class="span10">
            <div class="span4">{{ _('Description') }}</div>
            <div class="span7">{{ _('Command') }}</div>
            <div class="span1">{{ _('Enabled') }}</div>
        </div>
        <div style="margin-top: 5px" data-bind="foreach: analyzers">
          <div>
            <div class="span10">
              <input type="text" class="span4 text-left" data-bind="value: description">
              <input type="text" class="span7 text-left" data-bind="value: command">
              <input type="checkbox" style="margin-left: 20px" data-bind="checked: enabled">
            </div>
            <div class="span2">
              <a title="{{ _('Remove analyzer') }}" class="btn btn-danger" data-bind="click: $parent.removeAnalyzer"><i class="fa fa-trash-o"></i></a>
            </div>
          </div>
        </div>
        <div class="row-fluid">
          <div class="offset10 span2" style="margin-top: 5px">
            <a title="{{ _('Add analyzer') }}" class="btn btn-primary" data-bind="click: addAnalyzer"><i class="fa fa-plus"></i></a>
          </div>
        </div>
        <h3>{{ _('Debug') }}</h3>
        <h4>{{ _('Debug Analysis') }}</h4>
        {{ _('Analyze a file and then <a href="downloads/logs/plugin_PrintTimeGenius_engine.log">download the log</a>.
        If you see errors, <a href="https://github.com/eyal0/OctoPrint-PrintTimeGenius/issues">report them</a>.') }}
        <h4>{{ _('Debug Estimates') }}</h4>
        <p><span class="label label-important">{{ _('May slow down your printer') }}</span>
          <!-- Only translate the text, not the HTML! -->
          {{ _('If you want to make a graph of the print time estimate and compare with OctoPrint\'s built-in estimates:
          <ol>
            <li>In settings, go to Logging.</li>
            <li>Set "octoprint.plugins.PrintTimeGenius" level to "DEBUG".</li>
            <li>Click on the blue plus.</li>
            <li>Click on save.</li>
          </ol>
        </p>
        <p>
          Now print something and the log will fill with a <a href="https://en.wikipedia.org/wiki/Comma-separated_values">csv</a>.
          <a href="downloads/logs/plugin_PrintTimeGenius_engine.log">Download the log</a>, remove unnecessary lines, and import to a spreadsheet.
        </p>') }}
        <h3>{{ _('Compensation values') }}</h3>
        <table class="print-time-genius-table" style="border: 2px solid black;">
          <thead style="border: 1px solid black;">
            <tr>
              <th style="border-left: 1px black solid; border-right: 1px black solid;" colspan=4>{{ _('Actual') }}</th>
              <th style="border-left: 1px black solid; border-right: 1px black solid;" colspan=3>{{ _('Predicted') }}</th>
              <th style="border-left: 1px black solid; border-right: 1px black solid;" colspan=1>{{ _('Compensated') }}</th>
            </tr>
            <tr>
              <th style="border-left: 1px black solid;">{{ _('Heating') }}</th>
              <th>{{ _('Extruding') }}</th>
              <th>{{ _('Cooling') }}</th>
              <th style="border-right: 1px black solid;">{{ _('Total') }}</th>
              <th style="border-left: 1px black solid;">{{ _('Heating') }}</th>
              <th>{{ _('Extruding') }}</th>
              <th style="border-right: 1px black solid;">{{ _('Cooling') }}</th>
              <th style="border-left: 1px black solid; border-right: 1px black solid;">{{ _('Total') }}</th>
            </tr>
          </thead>
          <tbody data-bind="foreach: print_history">
            <tr>
              <td style="border-left: 1px black solid;" data-bind="text:
                             _.has($data, 'firstFilamentPrintTime') ?
                             firstFilamentPrintTime().toFixed(1) : ''"></td>
              <td data-bind="text:
                             _.has($data, 'lastFilamentPrintTime') && _.has($data, 'firstFilamentPrintTime') ?
                             (lastFilamentPrintTime()-firstFilamentPrintTime()).toFixed(1) : ''"></td>
              <td data-bind="text:
                             _.has($data, 'payload.time') && _.has($data, 'lastFilamentPrintTime') ?
                             (payload.time()-lastFilamentPrintTime()).toFixed(1) : ''"></td>
              <td style="border-right: 1px black solid; font-weight: bold"
                  data-bind="text:
                             _.has($data, 'payload.time') ?
                             payload.time().toFixed(1) : ''"></td>
              <td style="border-left: 1px black solid;" data-bind="text:
                             _.has($data, 'analysisFirstFilamentPrintTime') ?
                             analysisFirstFilamentPrintTime().toFixed(1) : ''"></td>
              <td data-bind="text:
                             _.has($data, 'analysisLastFilamentPrintTime') && _.has($data, 'analysisFirstFilamentPrintTime') ?
                             (analysisLastFilamentPrintTime()-analysisFirstFilamentPrintTime()).toFixed(1) : ''"></td>
              <td style="border-right: 1px black solid;" data-bind="text:
                             _.has($data, 'analysisPrintTime') && _.has($data, 'analysisLastFilamentPrintTime') ?
                             (analysisPrintTime()-analysisLastFilamentPrintTime()).toFixed(1) : ''"></td>
              <td style="border-left: 1px black solid; border-right: 1px black solid; font-weight: bold"
                  data-bind="text:
                             _.has($data, 'compensatedPrintTime') ?
                             compensatedPrintTime().toFixed(1) : ''"></td>
              <td>
                <a title="{{ _('Remove row, if this is an atypical sample and shouldn\'t be used for future compensation') }}" class="btn btn-danger" data-bind="click: $parent.removePrintHistoryRow"><i class="fa fa-trash-o"></i></a>
              </td>
            </tr>
          </tbody>
        </table>
      </div>
    </div>
  </div>
</form>
